package com.fhz.recyclerviewtest

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.ConcatAdapter
import androidx.recyclerview.widget.LinearLayoutManager
import com.fhz.recyclerviewtest.concatadapter.ButtonAdapter
import com.fhz.recyclerviewtest.concatadapter.TextAdapter
import com.fhz.recyclerviewtest.databinding.ActivityMainBinding
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

class MainActivity : AppCompatActivity() {
    lateinit var binding: ActivityMainBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)


        val mutableListOf = ArrayList<String>()
        mutableListOf.add("小明11")
        mutableListOf.add("小明11")
        mutableListOf.add("小明11")
        mutableListOf.add("小明11")
        mutableListOf.add("小明11")

        val daming = ArrayList<String>()
        daming.add("大明")
        daming.add("大明")
        daming.add("大明")
        daming.add("大明")
        daming.add("大明")
        daming.add("大明")


        val textAdapter = TextAdapter(this, mutableListOf)
        val textAdapter1 = TextAdapter(this, mutableListOf)
        val buttonAdapter = ButtonAdapter(this, daming)
        val config = ConcatAdapter.Config.Builder().setIsolateViewTypes(true).build()
        val concatAdapter = ConcatAdapter(config, textAdapter, buttonAdapter,textAdapter1)
        binding.rv.layoutManager = LinearLayoutManager(this)
        binding.rv.adapter = concatAdapter





////        binding.rv.layoutManager = LinearLayoutManager(this)
//        var user = User("小明",15,0)
//        var user1 = User("大明",16,1)
//        var user2 = User("中明",17,0)
//        var user3 = User("老明",18,1)
//        val list = ArrayList<User>()
//        list.add(user)
//        list.add(user1)
//        list.add(user2)
//        list.add(user3)
//
//       val  adapter = TestAdapter(list)
//        binding.rv.adapter = adapter



    }
}